package com.li.tms.common;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

@Getter
@Setter
@ToString
@Accessors(chain = true)
public class R<T> {

    private int code;
    private String msg;
    private T data;
    private boolean success;
    private long total;

    public R(int code, String msg, T data, Boolean success, long total) {
        this.code = code;
        this.msg = msg;
        this.data = data;
        this.success = success;
        this.total = total;
    }

    public R() {
    }

    // 先写2个是那么个意思，后面要覆盖递减参数的重载

    public static <T> R<T> success(int code,String msg,T data,long total) {
        return new R<T>(code,msg,data,true,total);
    }

    public static <T> R<T> error(int code,String msg,T data,long total) {
        return new R<T>(code,msg,data,false,total);
    }

}
